
<?php include("session.php"); ?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>基础信息管理</title>
	<link rel="stylesheet" type="text/css" href="../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../jquery.min.js"></script>
	<script type="text/javascript" src="../jquery.easyui.min.js"></script>
</head>
<body  >	

			
		
		<div class="easyui-tabs" style="width:1400px;height:600px">
		
		<div title="用户管理"  style="overflow:auto;padding:10px;">
		
		
		</div>
		
		<div title="角色管理"  style="overflow:auto;padding:10px;">
		
		
		</div>
	
	
		<div title="客户管理"  style="overflow:auto;padding:10px;">
				
			<div  style = "width:150px;float:left;">
			
				<ul class="easyui-tree"   url="../service/administration.php?defDep=<?php echo  $userVo->depID ?>" data-options="animate:true,onlyLeafCheck:true"  id="depID">
				
				</ul>
			
			</div>
					
					
	
					<table id="custMan"  style="width:1200px;height:400px" data-options="
								rownumbers:true,
								singleSelect:true,
								autoRowHeight:false,
								pagination:true,
								pageSize:10">
						<thead>
							<tr>
								<th data-options="field:'name',width:350">名称</th>
							
								<th data-options="field:'time',width:180,align:'right'">注册时间</th>
								<th data-options="field:'lon',width:170,align:'right'">经度</th>
								<th data-options="field:'lat',width:170,align:'right'">纬度</th>
								<th data-options="field:'parentName',width:165,align:'right'">父机构名称</th>
								
								<th data-options="field:'operation',width:80,align:'right'">操作 </th> 
							
								  
							</tr>
						</thead>
					</table>
					
					<div id ="tb" style = "text-align:right;">
					  <input type = "button" value = "添加客户" onclick="add_customer()">
					  
					</div>
					
			
		</div>

		</div>
		<script>
		
		function add_customer()
		{			
			traceWin1=window.open('addcustomer.html','编辑客户信息','height=600, width=800, top=100,left=500');
		
			$('#depID').tree({
				onClick: function(node){
					
					
					$('#custMan').datagrid({   
				url:'../../zend_obd/jsonAPI/customer.php?vin='+node.id
				}
			);
		
			}
		});
		}
		
		function adit_customer(id)
		{
			
			traceWin=window.open('aditcustomer.html?ID='+id,'编辑客户信息','height=600, width=800, top=100,left=500, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=yes, status=no');
			$('#depID').tree({
				onClick: function(node){
					
					
					$('#custMan').datagrid({   
				url:'../../zend_obd/jsonAPI/customer.php?vin='+node.id
				}
			);
		
			}
		});
		
		}
		
		

		function show_confirm(id)
		{
		
		var r=confirm("确认删除该客户吗？!");
		
		
		if (r==true)
		  {
		
			$('#custMan').datagrid({   
					url:'../../zend_obd/jsonAPI/deletecustomer.php?vin='+id
					}
				);
		  	alert("删除成功!");
		  }
		  
		  $('#depID').tree({
				onClick: function(node){
					
					
					$('#custMan').datagrid({   
				url:'../../zend_obd/jsonAPI/customer.php?vin='+node.id
				}
			);
		
			}
		});

		}
		
		$('#custMan').datagrid({
				toolbar: '#tb'
			});
		
		$('#custMan').datagrid({   
			 url:'../../zend_obd/jsonAPI/customerManage.php?vin='+'1077'
					 }
		); 
		
		
			$('#depID').tree({
				onClick: function(node){
					
					
					$('#custMan').datagrid({   
				url:'../../zend_obd/jsonAPI/customer.php?vin='+node.id
				}
			);
		
			}
		});
		
		
		
		</script>
		
		
		<script>
		function getData(){
			var rows = [];
			for(var i=1; i<=800; i++){
				var amount = Math.floor(Math.random()*1000);
				var price = Math.floor(Math.random()*1000);
				rows.push({
					inv: 'Inv No '+i,
					date: $.fn.datebox.defaults.formatter(new Date()),
					name: 'Name '+i,
					amount: amount,
					price: price,
					cost: amount*price,
					note: 'Note '+i
				});
			}
			return rows;
		}
		
		function pagerFilter(data){
			if (typeof data.length == 'number' && typeof data.splice == 'function'){	// is array
				data = {
					total: data.length,
					rows: data
				}
			}
			var custMan = $(this);
			var opts = custMan.datagrid('options');
			var pager = custMan.datagrid('getPager');
			pager.pagination({
				onSelectPage:function(pageNum, pageSize){
					opts.pageNumber = pageNum;
					opts.pageSize = pageSize;
					pager.pagination('refresh',{
						pageNumber:pageNum,
						pageSize:pageSize
					});
					custMan.datagrid('loadData',data);
				}
			});
			if (!data.originalRows){
				data.originalRows = (data.rows);
			}
			var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
			var end = start + parseInt(opts.pageSize);
			data.rows = (data.originalRows.slice(start, end));
			return data;
		}
		
		$(function(){
			$('#custMan').datagrid({loadFilter:pagerFilter}).datagrid('loadData', getData());
		});
	</script>
		

	

</body>
</html>
	
	